package test.movies;


import katris.selenium.tests.util.BaseTest;

import org.testng.Assert;
import org.testng.annotations.Test;
import test.movies.LoginPage;
import test.movies.MainPage;

public class CreateMovieDescription_Success extends BaseTest {
	

    // Logger variable
    private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger.getLogger(CreateMovieDescription_Success.class);
	
    // Film Name
    private String filmName = "Neptyn";
    
    // Year of creation
    private String filmYear = "2014";   

    
    //@Test(priority = 1)
    public void add_New_Description () {

        LOGGER.info("//========================================================");
        LOGGER.info("Starting test :  creating of new film description ");
        LOGGER.info("//========================================================");

        LoginPage authorize = new LoginPage(app.getWebDriver(), app.getMovieUrl());

        // open Login Page
        authorize.openMoviesServer();

        // check if Login page is open
        boolean checkLoginPage = authorize.checkIfLoginPageIsOpen();
        Assert.assertTrue(checkLoginPage, "Login page is not open!!!!");

        // Login to application
        MainPage main = authorize.authorization("admin", "admin");
        Assert.assertNotNull(main, "Error while authorization: Can't find fields to authorize");

        // check if Main page is open
        boolean checkMainPage = main.checkIfMainPageIsOpen();
        Assert.assertTrue(checkMainPage, "User is not authorised !!!!");

        // create new Description
        boolean checkCreation = main.createNewDescription(filmName,filmYear);
        Assert.assertTrue(checkCreation,"Error during creation of new description!!!!");

        //do Log out
        LoginPage doLogOut = main.logOut();
        Assert.assertNotNull(doLogOut,"Button LogOut is not found!!!");

        // check if Login page is open
        boolean backLoginPage = doLogOut.checkIfLoginPageIsOpen();
        Assert.assertTrue(backLoginPage, "Back to Login page is not done!!!!");

    }


}
